<template>
  <div>
    <el-dialog title="修改用户基本信息" :visible.sync="dialogVisible" width="400px">
      <el-form class="demo-form-inline" label-width="80px">
        <el-form-item label="登录名">
          <el-input v-model="data.loginName" />
        </el-form-item>
        <el-form-item label="用户名">
          <el-input v-model="data.userName" />
        </el-form-item>
        <el-form-item label="性别">
          <el-input v-model="data.sex" />
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit()">提 交</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import apiUser from "@/api/baseManager/user";
export default {
  name:'dialogEdit',
  data() {
    return {
      dialogVisible: false,
      data: {
        userId: '',
        userName: '',
        loginName:'',
        sex:''
      }
    }
  },
  methods: {
    //修改
    openEdit(id) {
      apiUser.get(id).then(res=>{
          let e = res.data.item;
          this.data = {
            userId: e.userId,
            userName: e.userName,
            loginName:e.loginName,
            sex:e.sex
          }
      })
      this.dialogVisible = true
    },
    //提交
    submit(){
      apiUser.update(this.data).then(res=>{
        this.$parent.getList(); //调父组件方法 刷新表格
        this.dialogVisible = false
      })
    }
  }
}
</script>

<style scoped>
</style>
